#ifndef X1B_H
#define X1B_H

#include "common.h"

// A net
template <AllegroVersion version>
struct x1B
{
    uint32_t t;
    uint32_t k;
    
    // Points to another `x1B`
    uint32_t next;
    
    uint32_t net_name;
    
    // Null
    uint32_t un2;
    
    // 17.x?
#if __cplusplus >= 202002L
    COND_FIELD(version >= A_172, uint32_t, un4);
#endif
    // Bit mask, not fully decoded
    // 0x0000 0002 = has net name?
    uint32_t type;
    
    // `x04`
    uint32_t ptr1;
    uint32_t ptr2;
    
    // `x03`
    // Points to a string like
    // `@\cc256xqfn-em_102612a_added_cap\.schematic(sch_1):aud_fsync_1v8`
    uint32_t path_str_ptr;
    
    // `x26`
    uint32_t ptr4;
    
    // `x1E`
    uint32_t model_ptr;
    
    // Null?
    uint32_t un3[2];
    
    // `x22`
    uint32_t ptr6;
    
    uint32_t TAIL;
    operator x1B<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

#if __cplusplus < 202002L
template <> struct x1B<A_172>
{
    uint32_t t;
    uint32_t k;

    // Points to another `x1B`
    uint32_t next;

    uint32_t net_name;

    // Null
    uint32_t un2;

    // 17.x?
    uint32_t un4;

    // Bit mask, not fully decoded
    // 0x0000 0002 = has net name?
    uint32_t type;

    // `x04`
    uint32_t ptr1;
    uint32_t ptr2;

    // `x03`
    // Points to a string like
    // `@\cc256xqfn-em_102612a_added_cap\.schematic(sch_1):aud_fsync_1v8`
    uint32_t path_str_ptr;

    // `x26`
    uint32_t ptr4;

    // `x1E`
    uint32_t model_ptr;

    // Null?
    uint32_t un3[2];

    // `x22`
    uint32_t ptr6;

    uint32_t TAIL;
    operator x1B<A_174>() const;
    static constexpr AllegroVersion versions[1] = {A_172};
};

template<> struct x1B<A_174> : x1B<A_172> {};
#endif

#endif // X1B_H
